class ifu2isu_seq_lib extends uvm_sequence_library #(tr_ifu2isu);
  `uvm_object_utils(ifu2isu_seq_lib)
  `uvm_sequence_library_utils(ifu2isu_seq_lib)
  
  function new(string name="ifu2isu_seq_lib");
    super.new(name);
    init_sequence_library();
  endfunction
endclass

class ifu2isu_simple_sequence extends uvm_sequence #(tr_ifu2isu);
  `uvm_object_utils(ifu2isu_simple_sequence)
  `uvm_add_to_seq_lib(ifu2isu_simple_sequence, ifu2isu_seq_lib)
  `uvm_declare_p_sequencer(ifu2isu_sequencer)
  
	tr_ifu2isu tr;
  
	virtual task body();
    `uvm_do(tr)
	endtask
endclass

class dpu2isu_seq_lib extends uvm_sequence_library #(tr_dpu2isu);
  `uvm_object_utils(dpu2isu_seq_lib)
  `uvm_sequence_library_utils(dpu2isu_seq_lib)
  
  function new(string name="dpu2isu_seq_lib");
    super.new(name);
    init_sequence_library();
  endfunction
endclass

class dpu2isu_simple_sequence extends uvm_sequence #(tr_dpu2isu);
  `uvm_object_utils(dpu2isu_simple_sequence)
  `uvm_add_to_seq_lib(dpu2isu_simple_sequence, dpu2isu_seq_lib)
  `uvm_declare_p_sequencer(dpu2isu_sequencer)
  
	tr_dpu2isu tr;
  
	virtual task body();
    `uvm_do(tr)
	endtask
endclass

class exu2isu_seq_lib extends uvm_sequence_library #(tr_exu2isu);
  `uvm_object_utils(exu2isu_seq_lib)
  `uvm_sequence_library_utils(exu2isu_seq_lib)
  
  function new(string name="exu2isu_seq_lib");
    super.new(name);
    init_sequence_library();
  endfunction
endclass

class exu2isu_simple_sequence extends uvm_sequence #(tr_exu2isu);
  `uvm_object_utils(exu2isu_simple_sequence)
  `uvm_add_to_seq_lib(exu2isu_simple_sequence, exu2isu_seq_lib)
  `uvm_declare_p_sequencer(exu2isu_sequencer)
  
	tr_exu2isu tr;
  
	virtual task body();
    `uvm_do(tr)
	endtask
endclass

class lsu2isu_seq_lib extends uvm_sequence_library #(tr_lsu2isu);
  `uvm_object_utils(lsu2isu_seq_lib)
  `uvm_sequence_library_utils(lsu2isu_seq_lib)
  
  function new(string name="lsu2isu_seq_lib");
    super.new(name);
    init_sequence_library();
  endfunction
endclass

class lsu2isu_simple_sequence extends uvm_sequence #(tr_lsu2isu);
  `uvm_object_utils(lsu2isu_simple_sequence)
  `uvm_add_to_seq_lib(lsu2isu_simple_sequence, lsu2isu_seq_lib)
  `uvm_declare_p_sequencer(lsu2isu_sequencer)
  
	tr_lsu2isu tr;
  
	virtual task body();
    `uvm_do(tr)
	endtask
endclass

class test_isu_env extends uvm_env;
  isu_agent agent;
  
  virtual tlm_sys_if.mods sysif;

  `uvm_component_utils_begin(test_isu_env)
  `uvm_component_utils_end
  
  virtual function void build_phase(uvm_phase phase);
    super.build_phase(phase);
///    set_config_int("core.ife*", "fw_trans", 1);
    
    agent = isu_agent::type_id::create("isu_agent", this);
  endfunction
  
  virtual function void connect_phase(uvm_phase phase);
    super.connect_phase(phase);
  endfunction
  
  virtual task run_phase(uvm_phase phase);
  endtask

  function new(string name, uvm_component parent);
    super.new(name, parent);
  endfunction : new
endclass

/// vsim +uvm_TESTNAME=ip4_ife_test work.top -novopt  -c -do "transcript off ; run 90ns ; quit -f" > log.txt
/// -novopt vsim +notimingchecks +uvm_TESTNAME=ip4_ife_test work.top -novopt
/// cd E:\work\ip4\design\sim
/// vlog -sv ..\tlm\ip4.sv +incdir+..\tlm\ +incdir+d:\questasim_6.6d\verilog_src\uvm-2.1.1\src\

class isu_test extends uvm_test;
  test_isu_env env;
  `uvm_component_utils_begin(isu_test)
  `uvm_component_utils_end
  
  virtual function void build_phase(uvm_phase phase);
    super.build_phase(phase);
  	uvm_config_db#(virtual xpip_intf)::set(this, "*", "inf", top.inf);
  	uvm_config_db#(virtual tlm_sys_if)::set(this, "*", "sysif", top.sysif); 
  	
  	uvm_config_db#(uvm_object_wrapper)::set(this,"*.ifu_sequencer.run_phase", "default_sequence", ifu2isu_seq_lib::type_id::get());
  	uvm_config_db#(uvm_object_wrapper)::set(this,"*.dpu_sequencer.run_phase", "default_sequence", dpu2isu_seq_lib::type_id::get());
  	uvm_config_db#(uvm_object_wrapper)::set(this,"*.lsu_sequencer.run_phase", "default_sequence", lsu2isu_seq_lib::type_id::get());
  	uvm_config_db#(uvm_object_wrapper)::set(this,"*.exu_sequencer.run_phase", "default_sequence", exu2isu_seq_lib::type_id::get());
  	
  	uvm_config_db#(uvm_sequence_lib_mode)::set(this, "*", "default_sequence.selection_mode", UVM_SEQ_LIB_RAND);   ///UVM_SEQ_LIB_ITEM
  	uvm_config_db#(int unsigned)::set(this, "*", "default_sequence.sequence_count", 100);
  	uvm_config_db#(int unsigned)::set(this, "*", "default_sequence.min_random_count", 100);
  	uvm_config_db#(int unsigned)::set(this, "*", "default_sequence.max_random_count", 100);
    uvm_config_db#(time)::set(this, "*", "runDelay", 6ns);

    env = test_isu_env::type_id::create("env", this);
  endfunction
  
   virtual function void end_of_elaboration_phase(uvm_phase phase);
    set_report_verbosity_level_hier(UVM_FULL); ///UVM_FULL UVM_MEDIUM UVM_HIGH UVM_LOW
  endfunction
    
  virtual task run_phase(uvm_phase phase);
  	tr_ifu2isu tr;

///    #20ns;
///  	tr = new();
///  	assert(tr.randomize());
///  	tr.fetchReq = '1;
///  	tr.pc = 32'h12300;
///  	tr.tid = $random;
///  	tr.cancel = '{default : '0};
    
///  	void'(env.ife_agent.ise_driver.nb_transport_ise(tr, tr));
    
  endtask

  function new(string name = "test_ife", uvm_component parent);
    super.new(name, parent);
  endfunction : new  
endclass